<?php
//简历系统
C_base::Dy('c.admin.adbase');
class recruit extends adbase{
	
	var $_vpath='admin/recruit/';  //定义调用模板所属一级文件夹
	var $_waiyu = array('不限','英语','日语','法语','韩语','德语','泰语','西班牙语','俄语','意大利语','葡萄牙语','斯瓦西里语','阿拉伯语','马来语','瑞典语','塞尔威亚语','波斯语','越南语','芬兰语','乌克兰语','捷克语','阿尔巴尼亚语','波兰语','缅甸语','僧伽罗语','豪萨语','印地语');
	var $_xueli = array('不限','高中以下','高中','中专/技校','大专','本科','硕士','博士','MBA/EMBA');
	var $_gzjy = array('不限','应届生','一年','两年','三年','三年-五年','五年-十年','十年以上');
	var $_xz = array('面议','1000元以下','1000-2000元','2000-3000元','3000-5000元','5000-8000元','8000-10000元','10000元以上');
	var $_danwei = array('元/小时','元/天','元/周','元/月');
	var $_youxiao = array('一周','两周','一月','两月','三月','半年','一年','两年','长期有效');
	var $_sex = array('保密','男','女');
	var $_hyzt = array('未婚','已婚');
	var $_shenfen = array('在校学生','社会人才');
	var $_yysp = array('不限','基础水平','独立运用','熟练运用');
	var $_cskill = array('不限','一般','熟练','精通');
	
	function __construct(){
		parent::__construct();
		$this->titl = '人力资源';
		$this->xurl = $this->_url.'/admin/?act=recruit'.$this->gnpd;
	}
	
	function index(){
		
	}
	
/************************************企业********************************************/
	function xuanze(){
		$this->title = '充值';
		$this->id = $this->_get('id');
	}
	/**
	 * 套餐类型 1季度 2半年 3年
	 */
	function cz(){
		$this->_is_html = 1;
		extract($this->_post());
		if (@$lx == '0'){
			$this->_cuowu('请选择套餐!');
		}
		if (@$id && @$lx) {
			$cx = C_base::M('admin.recruit')->qy_gw_tj_s(array('qid'=>$id));
			$mo = C_base::M('admin.xitonggl')->tc_s(array('id'=>$lx));
			if ($cx){
				$w = array('kxzjl+'=>$mo['kxz'],'kfb+'=>$mo['kfb']);
				$x = C_base::M('admin.recruit')->qy_gw_tj_u(array('qid'=>$id),$w);
			}else {
				$w = array('kxzjl'=>$mo['kxz'],'kfb'=>$mo['kfb']);
				$w['qid'] = $id;
				$x = C_base::M('admin.recruit')->qy_gw_tj_c($w);
			}
			if ($x) {
				$this->_cuowu('充值成功!');
			}else {
				$this->_cuowu('充值失败!');
			}
		}else {
			$this->_cuowu('非法操作!');
		}
	}
	
	function firm_xx(){//企业管理
		$this->tit = '企业管理';
		$this->rs = C_base::M('admin.recruit')->qy_ss();
	}
	
	function firm_hy($id){//根据行业id获取行业名称
		$rs = C_base::M('admin.recruit')->industry_s(array('id'=>$id));
		return @$rs['name'] ? $rs['name'] : '';
	}
	
	function firm_look(){//企业信息
		$this->tit = '企业信息';
		if(@$this->_get('id')){
			$this->r = C_base::M('admin.recruit')->qy_s(array('id'=>$this->_get('id')));
			if(@$this->r){
				$this->rs = C_base::M('admin.recruit')->qys_s(array('uid'=>$this->_get('id')));
				if(@$this->rs){
					if(@$this->rs['sshy']){
						$this->rs['sshy'] = $this->firm_hy($this->rs['sshy']);
					}
					$this->rs['sheng'] = $this->user_dz($this->rs['sheng']);
					$this->rs['shi'] = $this->user_dz($this->rs['shi']);
					$this->rs['qu'] = $this->user_dz($this->rs['qu']);
					if(@$this->rs['zid']){
						$this->rs['zname'] = $this->user_name($this->rs['zid'],1);
					}
				}
			}else{
				$this->_cuowu('非法操作');
			}
		}else{
			$this->_cuowu('非法操作');
		}
	}
	
	function firm_zw(){//职位管理
		$this->tit = '职位管理';
		$r = array();
		for($i=0;$i<10;$i++){
			$r[$i] = C_base::M('admin.recruit')->qy_gw_ss($i,array('style!'=>2));
		}
		$this->rs = util::arr_one($r);
	}
	
	function firm_zw_look(){//职位信息
		$this->tit = '职位信息';
		if(@$this->_get('id') && @$this->_get('qid')){
			$this->rs = C_base::M('admin.recruit')->qy_gw_s($this->_get('qid'),array('id'=>$this->_get('id')));
			if(@$this->rs){
				if(@$this->rs['sshy']){
					$this->rs['sshy'] = $this->firm_hy($this->rs['sshy']);
				}
				if(@$this->rs['zwlb']){
					$this->rs['zwlb'] = $this->user_zw($this->rs['zwlb']);
				}
				if(@$this->rs['zhiwei']){
					$this->rs['zhiwei'] = $this->user_zw($this->rs['zhiwei']);
				}
				$this->rs['sheng'] = $this->user_dz($this->rs['sheng']);
				$this->rs['shi'] = $this->user_dz($this->rs['shi']);
				$this->rs['qu'] = $this->user_dz($this->rs['qu']);
			}else{
				$this->_cuowu('非法操作');
			}
		}else{
			$this->_cuowu('非法操作');
		}
	}
	
	function firm_zwxx(){//职位信息
		extract($this->_get());
		$this->tit = '职位信息';
		$this->rs = C_base::M('admin.recruit')->qy_gw_s($qid,array('id'=>$id,'qid'=>$qid));
		$this->sh = C_base::M('admin.port')->linkage_ss(array('parent_id'=>'0'));//所有省列表
		if(@$this->rs['sheng']){
			$this->shi = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$this->rs['sheng']));
			if(@$this->rs['shi']){
				$this->qu = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$this->rs['shi']));
			}
		}
		$this->zhiwei = C_base::M('admin.recruit')->job_ss(array('sid'=>0));
		$this->hangye = C_base::M('admin.recruit')->industry_ss();//行业类别
	}
	
	function firm_jl(){//简历下载管理
		$this->tit = '简历下载管理';
		$r = array();
		for($i=0;$i<10;$i++){
			$r[$i] = C_base::M('admin.recruit')->jlxz_ss($i,array('lx'=>0));
		}
		$this->rs = util::arr_one($r);
		if($this->rs){
			foreach ($this->rs as $k=>$v){
				$qy = C_base::M('admin.recruit')->qys_s(array('uid'=>$v['qid']));
				$this->rs[$k]['qname'] = @$qy['qy_name'];
				$this->rs[$k]['uname'] = $this->user_name($v['uid']);
				$jl = C_base::M('admin.recruit')->resume_s($v['uid'],array('id'=>$v['jlid']));
				if(@$jl){
					$jlname = $this->user_zw($jl['zwlb']).'('.$this->user_zw($jl['zhiwei']).')';
					$this->rs[$k]['jlname'] = @$jl['title'] ? $jl['title'] : @$jlname;
				}else{
					$this->rs[$k]['jlname'] = '此简历已失效';
				}
			}
		}
	}
	
	function firm_jls(){//收到简历管理
		$this->tit = '收到简历管理';
		$r = array();
		for($i=0;$i<10;$i++){
			$r[$i] = C_base::M('admin.recruit')->qtoudi_ss($i);
		}
		$this->rs = util::arr_one($r);
		if($this->rs){
			foreach ($this->rs as $k=>$v){
				$qy = C_base::M('admin.recruit')->qys_s(array('uid'=>$v['qid']));
				$this->rs[$k]['qname'] = @$qy['qy_name'];
				$gw = C_base::M('admin.recruit')->qy_gw_s($v['qid'],array('id'=>$v['zid']));
				$this->rs[$k]['gname'] = @$gw['name'];
				$this->rs[$k]['uname'] = $this->user_name($v['uid']);
				$jl = C_base::M('admin.recruit')->resume_s($v['uid'],array('id'=>$v['jid']));
				if(@$jl){
					$jlname = $this->user_zw($jl['zwlb']).'('.$this->user_zw($jl['zhiwei']).')';
					$this->rs[$k]['jlname'] = @$jl['title'] ? $jl['title'] : @$jlname;
				}else{
					$this->rs[$k]['jlname'] = '此简历已失效';
				}
			}
		}
	}
	
/************************************个人********************************************/
/************************************用户管理*****************************************/
	function user(){//用户列表
		$this->tit = '个人用户';
		$this->rs = C_base::M('admin.recruit')->user_ss(array('lx'=>0));
		
	}
	
	function user_update(){//修改用户信息
		$this->tit = '修改用户信息';
		if(@$this->_get('id')){
			$this->user = C_base::M('admin.recruit')->user_s(array('id'=>$this->_get('id'),'lx'=>0));
			if(@$this->user){
				$this->user['base'] = C_base::M('admin.recruit')->ubase_s(array('uid'=>$this->_get('id')));
				$this->zhuany = C_base::M('admin.recruit')->major_ss();
				$this->sh = C_base::M('admin.port')->linkage_ss(array('parent_id'=>'0'));//所有省列表
				if(@$this->user['base']['xsheng']){
					$this->shi = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$this->user['base']['xsheng']));
					if(@$this->user['base']['xshi']){
						$this->qu = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$this->user['base']['xshi']));
					}
				}
				if(@$this->user['base']['hksheng']){
					$this->hkshi = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$this->user['base']['hksheng']));
					if(@$this->user['base']['hkshi']){
						$this->hkqu = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$this->user['base']['hkshi']));
					}
				}
			}else{
				$this->_cuowu('非法操作');
			}
		}else{
			$this->_cuowu('非法操作');
		}
	}
	
	function user_pd($post){//用户信息判断
		extract($post);
		$time = date('Y-m-d',time());//当前日期
		if(@$phone && !util::preg_phone($phone)){
			exit('手机格式错误');
		}elseif(@$email && !util::preg_email($email)){
			exit('邮箱格式错误');
		}elseif(@$cstime && ($cstime > $time)){
			exit('请正确填写出生日期');
		}elseif(@$sfzh && !util::preg_sfzh($sfzh)){
			exit('身份证号格式错误');
		}elseif(@$qq && !util::preg_qq($qq)){
			exit('qq格式错误');
		}elseif(@$pay && !@is_numeric($pay)){
			exit('积分总值必须为数字格式');
		}elseif(@$jifen && !@is_numeric($jifen)){
			exit('积分余额必须为数字格式');
		}elseif(@$name && !util::preg_name($name)){
			exit('请正确填写姓名');
		}
		if(@$name){
			$this->pd_name($name);
		}
		if(@$xsq){
			$this->pd_name($xsq,60);
		}
		if(@$hk){
			$this->pd_name($hk,60);
		}
		if(@$byyx){
			$this->pd_name($byyx,50);
		}
		if(@$zzmm){
			$this->pd_name($zzmm,6);
		}
	}
	
	function changelevel($pay){//根据积分改变等级
		$this->_is_html=1;
		if($pay < 10){
			$level = 0;
		}elseif($pay >= 10 && $pay < 20){
			$level = 1;
		}elseif($pay >= 20 && $pay < 30){
			$level = 2;
		}elseif($pay >= 30 && $pay < 50){
			$level = 3;
		}elseif($pay >= 50 && $pay < 100){
			$level = 4;
		}elseif($pay >= 100 && $pay < 150){
			$level = 5;
		}elseif($pay >= 150 && $pay < 200){
			$level = 6;
		}else{
			$level = 7;
		}
		return $level;
	}
	
	function user_bj(){//修改用户信息
		$this->_is_html=1;
		extract($this->_post());
		if(!@$id){
			exit('非法操作');
		}
		$user = C_base::M('admin.recruit')->user_s(array('id'=>$id,'lx'=>0));
		if(!@$user){
			exit('非法操作');
		}else{
			$this->user_pd($this->_post());
			$post = util::quchu($this->_post(),'id,phone,email,pay,slevel,vlevel,jifen');
			if(@$cstime){
				$post['cstime'] = strtotime($cstime);
			}
			if(@$bytime){
				$post['bytime'] = strtotime($bytime);
			}
			if($phone || $email || @$pay != '' || @$slevel != '' || @$vlevel != '' || @$jifen != ''){
				$level = $this->changelevel($pay);
				$sz = array('phone'=>$phone,'email'=>$email,'pay'=>$pay,'level'=>$level,'slevel'=>$slevel,'vlevel'=>$vlevel,'jifen'=>$jifen);
				$aa = C_base::M('admin.recruit')->user_u(array('id'=>$id),$sz);
			}
			$pd = C_base::M('admin.recruit')->ubase_s(array('uid'=>$id));
			if($pd){
				$aa = C_base::M('admin.recruit')->ubase_u(array('uid'=>$id),$post);
			}else{
				$c = array_merge($post,array('uid'=>$id));
				$aa = C_base::M('admin.recruit')->ubase_c($c);
			}
			if($aa){
				exit('修改成功');
			}else{
				exit('系统繁忙');
			}
		}
	}
	
	function user_delete(){//删除用户
		$this->_is_html=1;
		extract($this->_post());
		if(@$id){
			$pd = C_base::M('admin.recruit')->user_s(array('id'=>$id,'lx'=>0));
			if(@$pd){
				//删除用户信息表
				C_base::M('admin.recruit')->ubase_d(array('uid'=>$id));
				//删除用户统计表
				C_base::M('admin.recruit')->tongji_d(array('uid'=>$id));
				//删除用户简历表
				C_base::M('admin.recruit')->resume_del($id,array('uid'=>$id));
				//删除用户投递表
				C_base::M('admin.recruit')->toudi_del($id,array('uid'=>$id));
				//删除用户收藏表
				C_base::M('admin.recruit')->shoucang_del($id,array('uid'=>$id));
				//删除专家面试意见表
				C_base::M('admin.recruit')->view_del($id,array('uid'=>$id));
				//删除培训经历表
				C_base::M('admin.recruit')->look_del($id,array('uid'=>$id));
				//删除充值记录表
				C_base::M('admin.recruit')->pay_del($id,array('uid'=>$id));
				//删除用户表
				$d = C_base::M('admin.recruit')->user_d(array('id'=>$id));
				if(@$d){
					exit('删除成功');
				}else{
					exit('系统繁忙');
				}
			}else{
				exit('此用户不存在');
			}
		}else{
			exit('非法操作');
		}
	}
	
	function user_type(){//冻结/解冻
		$this->_is_html=1;
		extract($this->_post());
		if(@$id && (@$dongjie != '')){
			$pd = C_base::M('admin.recruit')->user_s(array('id'=>$id,'lx'=>0));
			if(@$pd){
				if($pd['dongjie'] == $dongjie){
					exit('ok');
				}else{
					$aa = C_base::M('admin.recruit')->user_u(array('id'=>$id),array('dongjie'=>$dongjie));
					if($aa){
						exit('ok');
					}else{
						exit('系统繁忙');
					}
				}
			}else{
				exit('此用户不存在');
			}
		}else{
			exit('非法操作');
		}
	}
	
	function user_pass(){//重置密码
		$this->_is_html=1;
		extract($this->_post());
		if(@$id){
			$pd = C_base::M('admin.recruit')->user_s(array('id'=>$id,'lx'=>0));
			if(@$pd){
				$aa = C_base::M('admin.recruit')->user_u(array('id'=>$id),array('pass'=>md5('123456')));
				if($aa){
					exit('重置成功');
				}else{
					exit('系统繁忙');
				}
			}else{
				exit('此用户不存在');
			}
		}else{
			exit('非法操作');
		}
	}
	
	function zj_name($uid){//获取专家用户名
		$yh= C_base::M('admin.recruit')->user_s(array('id'=>$uid));
		$yhm = @$yh['phone'] ? $yh['phone'] : @$yh['email'];
		if (@$yh['lx']== 2){
			$user = C_base::M('admin.recruit')->vbase_s(array('uid'=>$uid));
		}else{
			$user = C_base::M('admin.recruit')->ubase_s(array('uid'=>$uid));
		}
		$name = @$user['name'] ? $user['name'] : $yhm;
		return $name;
	}
	
	function user_name($uid,$type=0){//获取用户名
		$yh = C_base::M('admin.recruit')->user_s(array('id'=>$uid));
		$yhm = @$yh['phone'] ? $yh['phone'] : @$yh['email'];
		if($type == 1){//只获取注册时的账号
			return $yhm;
		}else{//有姓名获取姓名，没有姓名获取注册时的账号
			$user = C_base::M('admin.recruit')->ubase_s(array('uid'=>$uid));
			$name = @$user['name'] ? $user['name'] : $yhm;
			return $name;
		}
	}
	
	function user_dz($id){//根据地址id获取地址名称
		$rs = C_base::M('admin.port')->linkage_s(array('area_id'=>$id));
		return @$rs['area_name'] ? $rs['area_name'] : '';
	}
	
	function user_zw($id){//根据职位id获取职位名称
		$rs = C_base::M('admin.recruit')->job_s(array('id'=>$id));
		return @$rs['name'] ? $rs['name'] : '';
	}
	
	function user_zy($id){//根据专业id获取专业名称
		$rs = C_base::M('admin.recruit')->major_s(array('id'=>$id));
		return @$rs['name'] ? $rs['name'] : '';
	}
	
/************************************简历管理*****************************************/
	function resume(){//简历管理
		$this->tit = '个人简历';
		$r = array();
		for($i=0;$i<10;$i++){
			$r[$i] = C_base::M('admin.recruit')->resume_ss($i);
		}
		$this->rs = util::arr_one($r);
		if($this->rs){
			foreach ($this->rs as $k=>$v){
				$this->rs[$k]['zwname'] = $this->user_zw($v['zwlb']).'('.$this->user_zw($v['zhiwei']).')';
				$this->rs[$k]['qzshi'] = $this->user_dz($v['qzshi']);
				$this->rs[$k]['qzqu'] = $this->user_dz($v['qzqu']);
				
			}
		}
	}
	
	function resume_look(){//查看简历
		$this->tit = '查看简历信息';
		if(@$this->_get('id') && @$this->_get('uid')){
			$w = array('id'=>$this->_get('id'),'uid'=>$this->_get('uid'));
			$this->rs = C_base::M('admin.recruit')->resume_s($this->_get('uid'),$w);
			if($this->rs){
				$this->rs['xsheng'] = $this->user_dz($this->rs['xsheng']);
				$this->rs['xshi'] = $this->user_dz($this->rs['xshi']);
				$this->rs['xqu'] = $this->user_dz($this->rs['xqu']);
				$this->rs['hksheng'] = $this->user_dz($this->rs['hksheng']);
				$this->rs['hkshi'] = $this->user_dz($this->rs['hkshi']);
				$this->rs['hkqu'] = $this->user_dz($this->rs['hkqu']);
				$this->rs['qzsheng'] = $this->user_dz($this->rs['qzsheng']);
				$this->rs['qzshi'] = $this->user_dz($this->rs['qzshi']);
				$this->rs['qzqu'] = $this->user_dz($this->rs['qzqu']);
				$this->rs['zwlb'] = $this->user_zw($this->rs['zwlb']);
				$this->rs['zhiwei'] = $this->user_zw($this->rs['zhiwei']);
				$this->rs['zhuanye'] = $this->user_zy($this->rs['zhuanye']);
				$this->rs['pxjl'] = $this->ckpxjl($this->_get('uid'));
				$this->rs['view'] = $this->ckview($this->_get('uid'));
			}else{
				$this->_cuowu('非法操作');
			}
		}else{
			$this->_cuowu('非法操作');
		}
	}
	
	function resume_update(){//修改简历
		$this->tit = '修改简历信息';
		if(@$this->_get('id') && @$this->_get('uid')){
			$w = array('id'=>$this->_get('id'),'uid'=>$this->_get('uid'));
			$this->rs = C_base::M('admin.recruit')->resume_s($this->_get('uid'),$w);
			if($this->rs){
				$this->zhuany = C_base::M('admin.recruit')->major_ss();
				$this->zwlb = C_base::M('admin.recruit')->job_ss(array('sid'=>0));
				if(@$this->rs['zwlb']){
					$this->zhiwei = C_base::M('admin.recruit')->job_ss(array('sid'=>$this->rs['zwlb']));
				}
				$this->sh = C_base::M('admin.port')->linkage_ss(array('parent_id'=>'0'));//所有省列表
				if(@$this->rs['xsheng']){
					$this->shi = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$this->rs['xsheng']));
					if(@$this->rs['xshi']){
						$this->qu = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$this->rs['xshi']));
					}
				}
				if(@$this->rs['hksheng']){
					$this->hkshi = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$this->rs['hksheng']));
					if(@$this->rs['hkshi']){
						$this->hkqu = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$this->rs['hkshi']));
					}
				}
				if(@$this->rs['qzsheng']){
					$this->qzshi = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$this->rs['qzsheng']));
					if(@$this->rs['qzshi']){
						$this->qzqu = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$this->rs['qzshi']));
					}
				}
			}else{
				$this->_cuowu('非法操作');
			}
		}else{
			$this->_cuowu('非法操作');
		}
	}
	
	function resume_pd($post){//简历判断
		extract($post);
		$time = date('Y-m-d',time());//当前日期
		if(!@$name){
			exit('请填写姓名');
		}elseif(!@$touxiang){
			exit('请选择头像');
		}elseif(@$sex == ''){
			exit('请选择性别');
		}elseif(!@$minzu){
			exit('请填写民族');
		}elseif(!@$cstime){
			exit('请填写出生日期');
		}elseif(@$cstime && ($cstime > $time)){
			exit('请正确填写出生日期');
		}elseif(!@$xsheng || !@$xshi || !@$xqu || !@$xsq){
			exit('请填写现居住地');
		}elseif(!@$hksheng || !@$hkshi || !@$hkqu || !@$hk){
			exit('请填写户籍地址');
		}elseif(!@$zhuanye){
			exit('请填写专业');
		}elseif(!@$xueli){
			exit('请填写学历');
		}elseif(!@$shengao){
			exit('请填写身高');
		}elseif(!@$tizhong){
			exit('请填写体重');
		}elseif(!@$phone){
			exit('请填写手机号');
		}elseif(@$zt == 1 && @$shenfen == ''){
			exit('请选择我的身份');
		}elseif(@$zt != 1 && @$gzjy == ''){
			exit('请选择工作经验');
		}elseif(@$zt != 1 && !@$title){
			exit('请填写简历标题');
		}elseif(!@$zwlb){
			exit('请选择职位类别');
		}elseif(!@$zhiwei){
			exit('请选择职位类别');
		}elseif(!@$money){
			exit('请填写期望薪资');
		}elseif(!@$qzsheng || !@$qzshi){
			exit('请填写求职地区');
		}elseif(@$zt == 1 && @$youxiao == ''){
			exit('请填写有效期');
		}elseif(@$zt == 1 && !@$jztime){
			exit('请选择兼职时间');
		}elseif(@$shengao && !@is_numeric($shengao)){
			exit('身高必须为数字格式');
		}elseif(@$tizhong && !@is_numeric($tizhong)){
			exit('体重必须为数字格式');
		}elseif(@$email && !util::preg_email($email)){
			exit('邮箱格式错误');
		}elseif(@$phone && !util::preg_phone($phone)){
			exit('手机号格式错误');
		}elseif(@$money && !@is_numeric($money)){
			exit('薪资必须为数字格式');
		}elseif(@$name && !util::preg_name($name)){
			exit('请正确填写姓名');
		}
		$this->pd_name($name);
		$this->pd_name($minzu,10);
		$this->pd_name($xsq,60);
		$this->pd_name($hk,60);
		if(@$jieshao){
			$this->pd_name($jieshao,1000);
		}
		if(@$title){
			$this->pd_name($title,40);
		}
		if(@$qzsq){
			$this->pd_name($qzsq,60);
		}
		if(@$gzjl){
			$this->pd_name($gzjl,1600);
		}
	}
	
	function resume_bj(){//修改简历
		$this->_is_html=1;
		$post = $this->_post();
		extract($this->_post());
		if(@$cstime){
			$post['cstime'] = strtotime($cstime);
			$post['age'] = util::time_age($post['cstime']);
		}
		if(!@$id){
			exit('非法操作');
		}elseif(!@$uid){
			exit('非法操作');
		}else{
			$tj = array('id'=>$id,'uid'=>$uid);
			$ck = C_base::M('admin.recruit')->resume_s($uid,$tj);
			if($ck){
				$this->resume_pd(array_merge($this->_post(),array('zt'=>$ck['zt'])));
				$w = array('id'=>$id);
				$aa = C_base::M('admin.recruit')->resume_u($uid,$w,$post);
				if($aa){
					exit('修改成功');
				}else{
					exit('系统繁忙');
				}
			}else{
				exit('非法操作');
			}
		}
	}
	
	function resume_delete(){//删除简历
		$this->_is_html=1;
		extract($this->_post());
		if(@$id && @$uid){
			$pd = C_base::M('admin.recruit')->resume_s($uid,array('id'=>$id,'uid'=>$uid));
			if($pd){
				$del = C_base::M('admin.recruit')->resume_d($uid,array('id'=>$id));
				if($del){
					if(@$pd['zt'] == 1){//兼职
						$ziduan = 'jianzhi';
					}else{//全职
						$ziduan = 'quanzhi';
					}
					$this->user_tongji(array('uid'=>$uid,'ziduan'=>$ziduan,'type'=>'-'));
					exit('删除成功');
				}else{
					exit('系统繁忙');
				}
			}else{
				exit('非法操作');
			}
		}else{
			exit('非法操作');
		}
	}
	
	function resume_type(){//保密/开放
		$this->_is_html=1;
		extract($this->_post());
		if(@$id && @$uid && (@$type != '')){
			$pd = C_base::M('admin.recruit')->resume_s($uid,array('id'=>$id,'uid'=>$uid));
			if(@$pd){
				if($pd['type'] == $type){
					exit('ok');
				}else{
					$aa = C_base::M('admin.recruit')->resume_u($uid,array('id'=>$id),array('type'=>$type));
					if($aa){
						exit('ok');
					}else{
						exit('系统繁忙');
					}
				}
			}else{
				exit('此简历不存在');
			}
		}else{
			exit('非法操作');
		}
	}
	
	function resume_html($rs,$uid){
		$wordStr = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
				<head>
				<STYLE>
				BR.page { page-break-after: always }
				</STYLE>
				<style>
				.icheck{
					margin: 7px 0;
				}
				.icheck th,.icheck td{
					width: 50px;
					line-height:24px;
					font-weight:normal;
					font-size:12px;
					border: 1px solid #d9d9d9;
					text-align: center;
					color: #585858;
				}
				.icheck th{
					background: #f4f4f4;
				}
				</style>
				</head><body>';
		$age = util::time_age($rs['cstime']);//年龄
		$wordStr .= '<div>
						<h3>'.$this->user_name($rs['uid']).'（'.$this->_sex[$rs['sex']].' '.$age.'岁）</h3>
						<p><img src="'.$this->_url.'/material/photo.php?id='.$rs['touxiang'].'" width="173" height="173"/></p>
						<p>出生日期：'.date('Y-m-d',$rs['cstime']).'</p>
						<p>民族：'.$rs['minzu'].'</p>
						<p>最高学历：'.$this->_xueli[$rs['xueli']].'</p>
						<p>主修专业：'.$this->user_zy($rs['zhuanye']).'</p>
						<p>现居住地：'.$this->user_dz($rs['xsheng']).$this->user_dz($rs['xshi']).$this->user_dz($rs['xqu']).$rs['xsq'].'</p>
						<p>户籍地址：'.$this->user_dz($rs['hksheng']).$this->user_dz($rs['hkshi']).$this->user_dz($rs['hkqu']).$rs['hk'].'</p>
						<p>身高：'.$rs['shengao'].'cm</p>
						<p>体重：'.$rs['tizhong'].'kg</p>
						<p>电子邮箱：'.$rs['email'].'</p>
						<p>手机号码：'.$rs['phone'].'</p>
						<p style="word-break:break-all;">自我介绍：'.$rs['jieshao'].'</p>';
		if($rs['zt'] == 1){
			$wordStr .= '<p>我的身份：'.$this->_shenfen[$rs['shenfen']].'</p>';
		}else{
			if(@$rs['gzjy']){
				$wordStr .= '<p>工作经验：'.$this->_gzjy[$rs['gzjy']].'</p>';
			}
		}
		$wordStr .= '<h5>求职意向</h5>';
		if($rs['zt'] != 1){
			$wordStr .= '<p>简历标题:'.$rs['title'].'</p>';
		}
		$wordStr .= '<p>职位类别：'.$this->user_zw($rs['zwlb']).'('.$this->user_zw($rs['zhiwei']).')</p>
						<p>期望薪资：'.$rs['money'].$rs['danwei'].'</p>
						<p>求职地区：'.$this->user_dz($rs['qzsheng']).$this->user_dz($rs['qzshi']).$this->user_dz($rs['qzqu']).$rs['qzsq'].'</p>
						<p style="word-break:break-all;">工作经历：'.$rs['gzjl'].'</p>';
		if($rs['zt'] == 1){
			$wordStr .= '<p>有效期：'.$rs['youxiao'].'</p>
							<p>兼职时间：
							<table class="icheck">
							<thead>
							<tr>
							<th>&nbsp;</th>
							<th>星期一</th>
							<th>星期二</th>
							<th>星期三</th>
							<th>星期四</th>
							<th>星期五</th>
							<th>星期六</th>
							<th>星期日</th>
							</tr>
							</thead>
							<tbody>
							<tr>
							<th>上午</th>';
			for($i=1;$i<8;$i++){
				if(strpos($rs['jztime'],','.$i.'_1,') !== false){
					$wordStr .='<td>√</td>';
				}else{
					$wordStr .='<td></td>';
				}
			}
			$wordStr .= '</tr>
								<tr>
								<th>下午</th>';
			for($i=1;$i<8;$i++){
				if(strpos($rs['jztime'],','.$i.'_2,') !== false){
					$wordStr .='<td>√</td>';
				}else{
					$wordStr .='<td></td>';
				}
			}
			$wordStr .= '</tr>
								<tr>
								<th>晚上</th>';
			for($i=1;$i<8;$i++){
				if(strpos($rs['jztime'],','.$i.'_3,') !== false){
					$wordStr .='<td>√</td>';
				}else{
					$wordStr .='<td></td>';
				}
			}
			$wordStr .= '</tr>
								</tbody>
								</table>
								</p>';
		}
		$wordStr .= '<h5>培训经历</h5>
							<p style="word-break:break-all;">'.$this->ckpxjl($uid).'</p>
							<h5>专家面试意见</h5>
							<p style="word-break:break-all;">'.$this->ckview($uid).'</p>
							</div>';
		$wordStr .= '</body></html>';
		return $wordStr;
	}
	
	function resume_xiazai(){//下载简历
		$this->_is_html=1;
		if(@$this->_get('id') && @$this->_get('uid')){
			$uid = $this->_get('uid');
			$w = array('id'=>$this->_get('id'),'uid'=>$uid);
			$rs = C_base::M('admin.recruit')->resume_s($uid,$w);
			if($rs){
				header("Cache-Control: no-cache, must-revalidate");
				header("Pragma: no-cache");
				$wordStr = $this->resume_html($rs,$uid);
				$filename = $this->user_name($uid);
				header("Content-Type: application/doc");
				header("Content-Disposition: attachment; filename=" . $filename . ".doc");
				echo $wordStr;
			}else{
				$this->_cuowu('非法操作');
			}
		}else{
			$this->_cuowu('非法操作');
		}
	}
	
/************************************充值记录********************************************/	
	function pay(){
		$this->tit = '充值记录';
		$r = array();
		for($i=0;$i<10;$i++){
			$r[$i] = C_base::M('admin.recruit')->pay_ss($i);
		}
		$this->rs = util::arr_one($r);
		if($this->rs){
			foreach ($this->rs as $k=>$v){
				$this->rs[$k]['uname'] = $this->user_name($v['uid']);
			}
		}
	}
	
/************************************收藏职位********************************************/	
	function collection(){
		$this->tit = '收藏职位';
		$r = array();
		for($i=0;$i<10;$i++){
			$r[$i] = C_base::M('admin.recruit')->shoucang_ss($i);
		}
		$this->rs = util::arr_one($r);
		if($this->rs){
			foreach ($this->rs as $k=>$v){
				$this->rs[$k]['uname'] = $this->user_name($v['uid']);
				$zw = C_base::M('admin.recruit')->qy_gw_s($v['qid'],array('id'=>$v['zid']));
				if(@$zw['qy_name']){
					$this->rs[$k]['qyname'] = $zw['qy_name'];
				}else{
					$qyname = C_base::M('admin.recruit')->qys_s(array('uid'=>$v['qid']));
					$this->rs[$k]['qyname'] = @$qyname['qy_name'];
				}
				$this->rs[$k]['zwname'] = @$zw['name'] ? $zw['name'] : '此岗位已失效';
			}
		}
	}
	
	function collection_delete(){//取消收藏
		$this->_is_html=1;
		extract($this->_post());
		if(@$id && @$uid){
			$pd = C_base::M('admin.recruit')->shoucang_s($uid,array('id'=>$id,'uid'=>$uid));
			if($pd){
				$del = C_base::M('admin.recruit')->shoucang_d($uid,array('id'=>$id));
				if($del){
					exit('删除成功');
				}else{
					exit('系统繁忙');
				}
			}else{
				exit('非法操作');
			}
		}else{
			exit('非法操作');
		}
	}
	
/************************************职位申请历史******************************************/
	function apply(){
		$this->tit = '职位申请历史';
		$r = array();
		for($i=0;$i<10;$i++){
			$r[$i] = C_base::M('admin.recruit')->toudi_ss($i);
		}
		$this->rs = util::arr_one($r);
		if($this->rs){
			foreach ($this->rs as $k=>$v){
				$this->rs[$k]['uname'] = $this->user_name($v['uid']);
				$jl = C_base::M('admin.recruit')->resume_s($v['uid'],array('id'=>$v['jid']));
				$this->rs[$k]['jlname'] = ($jl['zt'] == 0) ? $jl['title'] : $this->user_zw($jl['zwlb']).'('.$this->user_zw($jl['zhiwei']).')';
				$zw = C_base::M('admin.recruit')->qy_gw_s($v['qid'],array('id'=>$v['zid']));
				if(@$zw['qy_name']){
					$this->rs[$k]['qyname'] = $zw['qy_name'];
				}else{
					$qyname = C_base::M('admin.recruit')->qys_s(array('uid'=>$v['qid']));
					$this->rs[$k]['qyname'] = @$qyname['qy_name'];
				}
				$this->rs[$k]['gwname'] = @$zw['name'] ? $zw['name'] : '此岗位已失效';
			}
		}
	}
	
	function apply_delete(){//删除职位申请历史
		$this->_is_html=1;
		extract($this->_post());
		if(@$id && @$uid){
			$pd = C_base::M('admin.recruit')->toudi_s($uid,array('id'=>$id,'uid'=>$uid));
			if($pd){
				$del = C_base::M('admin.recruit')->toudi_d($uid,array('id'=>$id));
				if($del){
					$this->user_tongji(array('uid'=>$uid,'ziduan'=>'toudi','type'=>'-'));
					exit('删除成功');
				}else{
					exit('系统繁忙');
				}
			}else{
				exit('非法操作');
			}
		}else{
			exit('非法操作');
		}
	}
	
/************************************培训经历********************************************/
	function pxjl(){
		$this->tit = '培训经历';
		if(@$this->_get('uid')){//查看某个用户的培训经历
			$uid = $this->_get('uid');
			$this->rs = C_base::M('admin.recruit')->look_ss($uid,array('uid'=>$uid));
		}else{
			$r = array();
			for($i=0;$i<10;$i++){
				$r[$i] = C_base::M('admin.recruit')->look_ss($i);
			}
			$this->rs = util::arr_one($r);
		}
		if($this->rs){
			foreach ($this->rs as $k=>$v){
				$this->rs[$k]['uname'] = $this->user_name($v['uid']);
				$this->rs[$k]['zjname'] = $this->zj_name($v['zjid']);
				$sp = C_base::M('admin.recruit')->sp_s($v['zjid'],array('id'=>$v['spid']));
				$this->rs[$k]['spname'] = @$sp['name'];
			}
		}
	}
	
	function ckpxjl($uid){//查看培训经历
		$pxjl = C_base::M('admin.recruit')->look_ss($uid,array('uid'=>$uid));
		$str = '';
		if($pxjl){
			foreach ($pxjl as $k=>$v){
				//专家名称
				$zjname = $this->zj_name($v['zjid']);
				//视频名称
				$sp = C_base::M('admin.recruit')->sp_s($v['zjid'],array('id'=>$v['spid']));
				$spname = @$sp['name'];
				//培训经历
				$time = date('Y-m-d H:i:s',$v['time']);
				$lx = ($v['lx'] == 1) ? '视频' : '文章';
				$str .= $time.'查看了'.$zjname.'发布的'.$lx.'【'.$spname.'】；<br>';
			}
		}
		return $str;
	}
	
/************************************专家面试意见******************************************/
	function view(){
		$this->tit = '专家面试意见';
		if(@$this->_get('uid')){//查看某个用户的专家面试意见
			$uid = $this->_get('uid');
			$this->rs = C_base::M('admin.recruit')->view_ss($uid,array('uid'=>$uid));
		}else{
			$r = array();
			for($i=0;$i<10;$i++){
				$r[$i] = C_base::M('admin.recruit')->view_ss($i);
			}
			$this->rs = util::arr_one($r);
		}
		if($this->rs){
			foreach ($this->rs as $k=>$v){
				$this->rs[$k]['uname'] = $this->user_name($v['uid']);
				$this->rs[$k]['zjname'] = $this->zj_name($v['zjid']);
			}
		}
	}
	
	function ckview($uid){//查看专家面试意见
		$rs = C_base::M('admin.recruit')->view_ss($uid,array('uid'=>$uid));
		$str = '';
		if($rs){
			foreach ($rs as $k=>$v){
				//专家名称
				$zjname = $this->zj_name($v['zjid']);
				//培训经历
				$str .= '专家【'.$zjname.'】评价：'.$v['view'].'；<br>';
			}
		}
		return $str;
	}
	
	function view_delete(){//删除专家面试意见
		$this->_is_html=1;
		extract($this->_post());
		if(@$id && @$uid){
			$pd = C_base::M('admin.recruit')->view_s($uid,array('id'=>$id,'uid'=>$uid));
			if($pd){
				$del = C_base::M('admin.recruit')->view_d($uid,array('id'=>$id));
				if($del){
					$this->user_tongji(array('uid'=>$uid,'ziduan'=>'view','type'=>'-'));
					exit('删除成功');
				}else{
					exit('系统繁忙');
				}
			}else{
				exit('非法操作');
			}
		}else{
			exit('非法操作');
		}
	}
	
/************************************用户统计********************************************/
	/**
	 * 用户数据统计
	 * $uid	用户id
	 * $ziduan	要统计的字段
	 * $type	操作。+-
	 */
	function user_tongji($post){
		extract($post);
		$w = array('uid'=>$uid);
		$pd = C_base::M('admin.recruit')->tongji_s($w);
		if($pd){
			$x = $ziduan.$type;
			$u = array($x=>1);
			C_base::M('admin.recruit')->tongji_u($w,$u);
		}else{
			$c = array('uid'=>$uid,$ziduan=>1);
			C_base::M('admin.recruit')->tongji_c($c);
		}
	}
/************************************职位类别********************************************/
	function pd_name($name,$len='30'){//名称判断
		$na = mb_ereg_replace('^(　| )+','', $name);//去除全角字符的空格
		$nam = mb_ereg_replace('(　| )+$','', $na);//去除全角字符的空格
		$cd=(strlen(trim($nam)) + mb_strlen(trim($nam),'UTF8'))/2;
		if(trim($nam)){
			if($cd > $len){
				$zi = $len/2;
				exit('名称不能超过'.$zi.'个字');
			}
		}else{
			exit('名称不能为空');
		}
	}
	
	function job(){//职位类别
		$this->tit = '职位类别';
		$this->da = C_base::M('admin.recruit')->job_ss(array('sid'=>0));
		if(@$this->_get('sid')){//查看小分类
			$this->rs = C_base::M('admin.recruit')->job_ss(array('sid'=>$this->_get('sid')));
		}else{//大分类
			$this->rs = C_base::M('admin.recruit')->job_ss(array('sid'=>0));
		}
	}
	
	function job_add(){//添加职位
		$this->_is_html=1;
		if(@$this->_post('name') != ''){
			$this->pd_name($this->_post('name'));
			$w = array('name'=>$this->_post('name'));
			$pd = C_base::M('admin.recruit')->job_s($w);
			if($pd){
				exit('此职位已存在');
			}else{
				$rs = C_base::M('admin.recruit')->job_c($this->_post());
				if(@$rs){
					exit('添加成功');
				}else{
					exit('系统繁忙');
				}
			}
		}else{
			exit('请填写职位名称');
		}
	}
	
	function job_update(){//修改职位
		$this->_is_html=1;
		if(@$this->_post('name') != '' && $this->_post('id') != ''){
			$this->pd_name($this->_post('name'));
			$w = array('name'=>$this->_post('name'),'id!'=>$this->_post('id'));
			$pd = C_base::M('admin.recruit')->job_s($w);
			if($pd){
				exit('此职位已存在');
			}else{
				$w = array('id'=>$this->_post('id'));
				$u = array('name'=>$this->_post('name'));
				$rs = C_base::M('admin.recruit')->job_u($w,$u);
				if(@$rs){
					exit('修改成功');
				}else{
					exit('系统繁忙');
				}
			}
		}else{
			exit('非法操作');
		}
	}
	
	function job_del(){//删除职位
		$this->_is_html=1;
		if($this->_post('id') != ''){
			$w = array('id'=>$this->_post('id'));
			$pd = C_base::M('admin.recruit')->job_s($w);
			if($pd){
				$ck = C_base::M('admin.recruit')->job_s(array('sid'=>$this->_post('id')));
				if($ck){//删除大类时给出提示
					exit('此分类下有小分类，不能删除');
				}else{
					$rs = C_base::M('admin.recruit')->job_d($w);
					if(@$rs){
						exit('删除成功');
					}else{
						exit('系统繁忙');
					}
				}
			}else{
				exit('非法操作');
			}
		}else{
			exit('非法操作');
		}
	}
	
/************************************行业类别********************************************/
	function industry(){//行业类别
		$this->tit = '行业类别';
		$this->rs = C_base::M('admin.recruit')->industry_ss();
	
	}
	
	function industry_add(){//添加行业
		$this->_is_html=1;
		if(@$this->_post('name') != ''){
			$this->pd_name($this->_post('name'));
			$w = array('name'=>$this->_post('name'));
			$pd = C_base::M('admin.recruit')->industry_s($w);
			if($pd){
				exit('此行业已存在');
			}else{
				$rs = C_base::M('admin.recruit')->industry_c($w);
				if(@$rs){
					exit('添加成功');
				}else{
					exit('系统繁忙');
				}
			}
		}else{
			exit('请填写行业名称');
		}
	}
	
	function industry_update(){//修改行业
		$this->_is_html=1;
		if(@$this->_post('name') != '' && $this->_post('id') != ''){
			$this->pd_name($this->_post('name'));
			$w = array('name'=>$this->_post('name'),'id!'=>$this->_post('id'));
			$pd = C_base::M('admin.recruit')->industry_s($w);
			if($pd){
				exit('此行业已存在');
			}else{
				$w = array('id'=>$this->_post('id'));
				$u = array('name'=>$this->_post('name'));
				$rs = C_base::M('admin.recruit')->industry_u($w,$u);
				if(@$rs){
					exit('修改成功');
				}else{
					exit('系统繁忙');
				}
			}
		}else{
			exit('非法操作');
		}
	}
	
	function industry_del(){//删除行业
		$this->_is_html=1;
		if($this->_post('id') != ''){
			$w = array('id'=>$this->_post('id'));
			$pd = C_base::M('admin.recruit')->industry_s($w);
			if($pd){
				$rs = C_base::M('admin.recruit')->industry_d($w);
				if(@$rs){
					exit('删除成功');
				}else{
					exit('系统繁忙');
				}
			}else{
				exit('非法操作');
			}
		}else{
			exit('非法操作');
		}
	}
	
/************************************专业类别********************************************/
	function major(){//专业类别
		$this->tit = '专业类别';
		$this->da = C_base::M('admin.recruit')->major_ss(array('sid'=>0));
		if(@$this->_get('sid')){//查看小分类
			$this->rs = C_base::M('admin.recruit')->major_ss(array('sid'=>$this->_get('sid')));
		}else{//大分类
			$this->rs = C_base::M('admin.recruit')->major_ss(array('sid'=>0));
		}
	}
	
	function major_add(){//添加专业
		$this->_is_html=1;
		if(@$this->_post('name') != ''){
			$this->pd_name($this->_post('name'));
			$w = array('name'=>$this->_post('name'));
			$pd = C_base::M('admin.recruit')->major_s($w);
			if($pd){
				exit('此专业已存在');
			}else{
				$rs = C_base::M('admin.recruit')->major_c($this->_post());
				if(@$rs){
					exit('添加成功');
				}else{
					exit('系统繁忙');
				}
			}
		}else{
			exit('请填写专业名称');
		}
	}
	
	function major_update(){//修改专业
		$this->_is_html=1;
		if(@$this->_post('name') != '' && $this->_post('id') != ''){
			$this->pd_name($this->_post('name'));
			$w = array('name'=>$this->_post('name'),'id!'=>$this->_post('id'));
			$pd = C_base::M('admin.recruit')->major_s($w);
			if($pd){
				exit('此专业已存在');
			}else{
				$w = array('id'=>$this->_post('id'));
				$u = array('name'=>$this->_post('name'));
				$rs = C_base::M('admin.recruit')->major_u($w,$u);
				if(@$rs){
					exit('修改成功');
				}else{
					exit('系统繁忙');
				}
			}
		}else{
			exit('非法操作');
		}
	}
	
	function major_del(){//删除专业
		$this->_is_html=1;
		if($this->_post('id') != ''){
			$w = array('id'=>$this->_post('id'));
			$pd = C_base::M('admin.recruit')->major_s($w);
			if($pd){
				$rs = C_base::M('admin.recruit')->major_d($w);
				if(@$rs){
					exit('删除成功');
				}else{
					exit('系统繁忙');
				}
			}else{
				exit('非法操作');
			}
		}else{
			exit('非法操作');
		}
	}
/****************************专家*****************************************/	
	function xuanzes(){//专家充值
		$this->title = '充值';
		$this->id = $this->_get('id');
	}
	
	function czs(){
		$this->_is_html = 1;
		extract($this->_post());
		if (@$lx == '0'){
			$this->_cuowu('请选择套餐!');
		}
		if (@$id && @$lx) {
			$cx = C_base::M('admin.recruit')->zjtongji_s(array('zjid'=>$id));
			$mo = C_base::M('admin.xitonggl')->tc_s(array('id'=>$lx));
			if ($cx){
				$w = array('jlfs+'=>$mo['kxz'],'jlgmfs+'=>$mo['kxz'],'kfb+'=>$mo['kfb']);
				$x = C_base::M('admin.recruit')->zjtongji_u(array('zjid'=>$id),$w);
			}else {
				$w = array('jlfs'=>$mo['kxz'],'jlgmfs'=>$mo['kxz'],'kfb'=>$mo['kfb']);
				$w['zjid'] = $id;
				$x = C_base::M('admin.recruit')->zjtongji_c($w);
			}
			if ($x) {
				$this->_cuowu('充值成功!');
			}else {
				$this->_cuowu('充值失败!');
			}
		}else {
			$this->_cuowu('非法操作!');
		}
	}
	
	function zjiagl(){
		$this->tit ='普通专家管理';
		$this->rs = C_base::M('admin.recruit')->user_ss(array('lx'=>1));
	}
	
	function vipzjiagl(){
		$this->tit ='VIP专家管理';
		$this->rs = C_base::M('admin.recruit')->user_ss(array('lx'=>2));
	}
	
	function zjia_tjvip(){
		$this->tit ='创建VIP专家';
		$this->sh = C_base::M('admin.port')->linkage_ss(array('parent_id'=>'0'));//所有省列表
	}
	
	/**
	 * 创建/编辑VIP专家
	 */
	function tjvip_sck(){
		extract($this->_post());
		$cz = @$this->_get('uid');
		$touxiang= C_base::dybase('util')->sctp('touxiang'); //专家头像
		$sfzsmj= C_base::dybase('util')->sctp('sfzsmj'); //身份证扫描件
		$gzzmsmj= C_base::dybase('util')->sctp('gzzmsmj'); //工作证明扫描件
		$post = util::quchu($this->_post(),'email,phone,level,pass,pass1');
		if($touxiang){$post['touxiang']=$touxiang;}
		if($sfzsmj){$post['sfzsmj']=$sfzsmj;};
		if($gzzmsmj){$post['gzzmsmj']=$gzzmsmj;};
		if(@$cstime){
			$post['cstime']= strtotime($cstime);
		}
		self::vbasepd($this->_post());		
		if(@$cz){  //编辑
			$user = C_base::M('admin.recruit')->user_s(array('phone'=>$phone,'id!'=>$cz));
			if(@$email){
				$users =  C_base::M('admin.recruit')->user_s(array('email'=>@$email,'id!'=>$cz));
			}
		}else{
			$user = C_base::M('admin.recruit')->user_s(array('phone'=>$phone));
			if(@$email){
				$users = C_base::M('admin.recruit')->user_s(array('email'=>@$email));
			}
		}
		if(@$user || @$users){
			$this->_cuowu('此账号已存在');
		}
		if(@$cz){  //编辑
			if($phone || $level || $email){
				$sz = array('phone'=>$phone,'level'=>$level,'email'=>$email);
				C_base::M('admin.recruit')->user_u(array('id'=>$cz),$sz);
			}
			$aa = C_base::M('admin.recruit')->vbase_u(array('uid'=>$cz),$post);
			$wz = '修改';
		}else{ //创建
			if(!util::preg_pass($pass)){
				//exit('请正确填写密码，密码由字母和数字组合且长度在6-12个字符之间');
				$this->_cuowu('请正确填写密码，密码由字母和数字组合且长度在6-12个字符之间');
			}elseif($pass != $pass1){
				//exit('两次密码不一致');
				$this->_cuowu('两次密码不一致');
			}elseif(!@$touxiang){
				//exit('请选择头像');
				$this->_cuowu('请选择头像');
			}
			$w = array('phone'=>$phone,'type'=>1,'lx'=>2,'pass'=>md5($pass),'time'=>time(),'level'=>$level,'email'=>@$email);
			$uid = C_base::M('admin.recruit')->user_c($w);
			if($uid){
				$c = array_merge($post,array('uid'=>$uid));
				//写入统计表
				if(@$jlxzlx == 2){ //半年
					$yxjstime = strtotime("6 month");
				}elseif(@$jlxzlx == 3){ //一年
					$yxjstime = strtotime("1 years");
				}elseif(@$jlxzlx == 1){  //1季度
					$yxjstime = strtotime("3 month");
				}else{
					//exit('请选择简历下载类型');
					$this->_cuowu('请选择简历下载类型');
				}
				C_base::M('admin.recruit')->zjtongji_c(array('zjid'=>$uid,'fenzu'=>$jlxzlx,'jlgmfs'=>$jlxzsx,'jlfs'=>$jlxzsx,'yxkstime'=>time(),'yxjstime'=>$yxjstime));
				$aa = C_base::M('admin.recruit')->vbase_c($c);
				$wz = '创建';
			}else{
				//exit('系统繁忙');
				$this->_cuowu('系统繁忙');
			}
		}
		if($aa){
			$this->_alert_location($this->_url.'/admin/?act=recruit&met=vipzjiagl'.$this->gnpd,$wz.'成功');
		}else{
			$this->_cuowu($wz.'失败');
		}
	}
	
	function vbasepd($post){
		extract($post);
		if(!@$phone || !util::preg_phone($phone)){
			//exit('请正确填写手机号');
			$this->_cuowu('请正确填写手机号');
		}elseif(!@$name){
			//exit('请填写姓名');
			$this->_cuowu('请填写姓名');
		}elseif(!@$cstime){
			//exit('请填写出生日期');
			$this->_cuowu('请填写出生日期');
		}elseif(@$cstime && ($cstime > time())){
			//exit('请正确填写出生日期');
			$this->_cuowu('请正确填写出生日期');
		}elseif(!@$xsheng || !@$xshi || !@$xqu || !@$xsq){
			//exit('请填写现居住地');
			$this->_cuowu('请填写现居住地');
		}elseif(!@$sfzh){
			//exit('请填写身份证号');
			$this->_cuowu('请填写身份证号');
		}elseif(!util::preg_sfzh($sfzh)){
			//exit('身份证号格式错误');
			$this->_cuowu('身份证号格式错误');
		}elseif(!@$scly){
			//exit('请填写擅长领域');
			$this->_cuowu('请填写擅长领域');
		}elseif(!@$byyx){
			//exit('请填写毕业院校');
			$this->_cuowu('请填写毕业院校');
		}elseif(@$email && !@util::preg_email($email)){
			//exit('邮箱格式错误');
			$this->_cuowu('邮箱格式错误');
		}
	}
	/**
	 * 查看专家详情
	 * id 专家id
	 */
	function zjiagl_xx(){
		$this->tit = '专家信息';
		self::gongy();
		if($this->user['base']){
			$this->sheng =$this->user_dz($this->user['base']['xsheng']);//所有省列表
			$this->shi = $this->user_dz($this->user['base']['xshi']);
			$this->qu = $this->user_dz($this->user['base']['xqu']);
			if($this->user['lx'] ==1){
				$this->hksheng =$this->user_dz($this->user['base']['hksheng']);//所有省列表
				$this->hkshi = $this->user_dz($this->user['base']['hkshi']);
				$this->hkqu = $this->user_dz($this->user['base']['hkqu']);
				$zhuany = C_base::M('admin.recruit')->major_s(array('id'=>$this->user['base']['zhuanye']));
				$this->user['base']['zhuanyes'] = @$zhuany['name'];
			}
		}
	}
	/**
	 * 普通专家编辑
	 */
	function zhuangjia_sck(){//修改用户信息
		$this->_is_html=1;
		extract($this->_post());
		$id = @$this->_get('uid');
		if(!@$id){
			exit('非法操作');
		}
		$user = C_base::M('admin.recruit')->user_s(array('id'=>$id,'lx'=>1));
		if(!@$user){
			exit('非法操作');
		}else{
			//$this->user_pd($this->_post());
			$post = util::quchu($this->_post(),'id,phone,email,level');
			$touxiang= C_base::dybase('util')->sctp('touxiang'); //专家头像
			$sfzsmj= C_base::dybase('util')->sctp('sfzsmj'); //身份证扫描件
			$gzzmsmj= C_base::dybase('util')->sctp('gzzmsmj'); //工作证明扫描件
			if($touxiang){$post['touxiang']=$touxiang;}
			if($sfzsmj){$post['sfzsmj']=$sfzsmj;};
			if($gzzmsmj){$post['gzzmsmj']=$gzzmsmj;};
			if(@$cstime){
				$post['cstime'] = strtotime($cstime);
			}
			if(@$bytime){
				$post['bytime'] = strtotime($bytime);
			}
			if(@$phone || @$email || @$level){
				if(@$phone){
					$uu = C_base::M('admin.recruit')->user_s(array('id!'=>$id,'phone'=>$phone));
					if($uu){
						exit('此手机号已存在');
					}
				}
				if(@$email){
					$ss = C_base::M('admin.recruit')->user_s(array('id!'=>$id,'email'=>$email));
					if($ss){
						exit('此邮箱已存在');
					}
				}
				$sz = array('phone'=>@$phone,'email'=>@$email,'level'=>@$level);
				$aa = C_base::M('admin.recruit')->user_u(array('id'=>$id),$sz);
			}
			$pd = C_base::M('admin.recruit')->ubase_s(array('uid'=>$id));
			if($pd){
				$aa = C_base::M('admin.recruit')->ubase_u(array('uid'=>$id),$post);
			}else{
				$c = array_merge($post,array('uid'=>$id));
				$aa = C_base::M('admin.recruit')->ubase_c($c);
			}
			if($aa){
				$this->_cuowu('修改成功');
			}else{
				$this->_cuowu('系统繁忙');
			}
		}
	}
	
	function gongy(){
		$this->user = C_base::M('admin.recruit')->user_s(array('id'=>@$this->_get('id')));
		if($this->user['lx'] == 1){  //普通专家
			$this->user['base'] = C_base::M('admin.recruit')->ubase_s(array('uid'=>$this->_get('id')));
		}elseif($this->user['lx'] == 2){  //vip专家
			$this->user['base'] = C_base::M('admin.recruit')->vbase_s(array('uid'=>$this->_get('id')));
		}else{
			$this->_cuowu('问题账号');
		}
	}
	/**
	 * 编辑专家
	 */
 	function zjiagl_bianjiym(){
		$this->tit ='专家编辑';
		self::gongy();
		$this->sh = C_base::M('admin.port')->linkage_ss(array('parent_id'=>'0'));//所有省列表
		$this->sshi = C_base::M('admin.port')->linkage_ss(array('parent_id'=>@$this->user['base']['xsheng']));
		$this->squ = C_base::M('admin.port')->linkage_ss(array('parent_id'=>@$this->user['base']['xshi']));
		$this->zhuany = C_base::M('admin.recruit')->major_ss();
		if(@$this->user['base']['hksheng']){
			$this->shkshi = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$this->user['base']['hksheng']));
			if(@$this->user['base']['hkshi']){
				$this->shkqu = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$this->user['base']['hkshi']));
			}
		}
		//self::zjiagl_xx();			
	} 
	
	/**
	 * 编辑.冻结/重置/
	 * id 专家id
	 * type 1冻结 2重置密码
	 */
	function zjia_bianji(){
		$this->_is_html = 1;
		extract($this->_post());
		$w = array('id'=>@$id);
		$user = C_base::M('admin.recruit')->user_s($w);
		if($user){
			if(@$type == 1){  //冻结
				if($user['dongjie'] == 0){
					$u = array('dongjie'=>1);
				}else{
					$u = array('dongjie'=>0);
				}
				$rs = C_base::M('admin.recruit')->user_u($w,$u);
			}elseif (@$type == 2){  //重置
				$rs = C_base::M('admin.recruit')->user_u($w,array('pass'=>md5('123456')));
			}else{
				exit('非法请求');
			}
			if(@$rs){
				exit('cg');
			}else{
				exit('error');
			}
		}else{
			exit('账号异常');
		}
	}
	
/**********************************课程管理*******************************************/		
	function zjia_spgl(){
		$this->tit ='课程管理';
		for($i=0;$i<=9;$i++){
			$rrs[$i] =  C_base::M('admin.recruit')->sp_ss($i);
		}
		if(@$rrs){
			foreach ($rrs as $k=>$v){
				if($v){
					foreach ($v as $kk=>$vv){
						$this->rs[]=$vv;
					}
				}
			}
		}
	}
	
	function zjia_spxx(){
		$this->tit ='视频详情';
		if(@!$this->_get('spid') || @!$this->_get('zjid')){
			exit('非法操作');
		}
		if(@$this->_get('bj')){  //编辑视频
			$this->bj =1;
			$this->tit ='编辑视频';
		}
		$this->rs = C_base::M('admin.recruit')->sp_s(@$this->_get('zjid'),array('id'=>$this->_get('spid')));
		if(@$this->rs['shipin']){
			$aa = str_replace(DS,'/',$this->rs['shipin']);
			$this->lj =$this->_url.$aa;
		}
	}
	
	/**
	 * zjid 专家id
	 * spid 视频id
	 * name 视频名称
	 * content 视频描述
	 * jifen 观看扣除积分
	 */
	function zjia_spbj(){
		$this->_is_html = 1;
		extract($this->_post());
		$na = mb_ereg_replace('^(　| )+','', $name);//去除全角字符的空格
		$nam = mb_ereg_replace('(　| )+$','', $na);//去除全角字符的空格
		if(trim($nam)){
			$con=(strlen(trim($nam)) + mb_strlen(trim($nam),'UTF8'))/2;
			if($con > 60){
				exit('名称不能超过60个字符【30个汉字】');
			}
		}else{
			exit('视频名称不能为空');
		}
		if(@!$jifen < 0 || @!preg_match('/^[0-9]*$/', $jifen)){
			exit('扣除数量必须为不为负数的整数');
		}
		$cz = C_base::M('admin.recruit')->sp_s(@$zjid,array('id'=>@$spid));
		if($cz){
			$rs = C_base::M('admin.recruit')->sp_u(array('zjid'=>@$zjid,'id'=>@$spid),array('name'=>$name,'content'=>$content,'jifen'=>$jifen));
			if($rs){
				exit('修改成功');
			}else{
				exit('修改失败');
			}
		}else{
			exit('error');
		}
	}
	
	/**
	 * spid 视频id
	 * zjid 专家id
	 * 1 同意 2拒绝
	 */
	function spshenghe(){
		$this->_is_html =1;
		extract($this->_post());
		$spxx = C_base::M('admin.recruit')->sp_s(@$zjid,array('id'=>@$spid));
		if($spxx){
			$w = array('zjid'=>$zjid,'id'=>$spid);
			if(@$type){
				if($spxx['zt']!=1){
					exit('未审核视频不能推荐');
				}
				if($spxx['tuijian'] == 1){
					$u = array('tuijian'=>0);
				}else{
					$u = array('tuijian'=>1);
				}
			}else{
				$u = array('zt'=>$zt,'stime'=>time());				
			}
			$rs = C_base::M('admin.recruit')->sp_u($w,$u);
			if(@$rs){
				exit('cg');
			}else{
				exit('审核失败');
			}
		}else{
			exit('已过期');
		}
	}
	
	function zjia_gwgl(){
		$this->tit ='专家招聘管理';
		$this->rs = self::zhaop('1');		
	}	
	
	function vzjia_gwgl(){
		$this->tit ='VIP专家招聘管理';
		$this->rs = self::zhaop('2');
	}
	
	function zhaop($style){
		for($i=0;$i<=9;$i++){
			$rrs[$i] =  C_base::M('admin.recruit')->qy_gw_ss($i,array('style'=>$style));
		}
		if(@$rrs){
			foreach ($rrs as $k=>$v){
				if($v){
					foreach ($v as $kk=>$vv){
						$rs[]=$vv;
					}
				}
			}
			if(@$rs){
				foreach ($rs as $k1=>$v1){
					if($style == '1'){
						$zz = C_base::M('admin.recruit')->user_s(array('qyid'=>$vv['qid']));
						$rs[$k1]['zjid'] = @$zz['id'];
					}
				}
			    return $rs;
			}
		}
	}
	/**
	 * id 岗位id
	 * qid 企业id
	 */
	function zjia_gwxx(){
		extract($this->_get());
		$this->tit = '岗位查看';
		$this->rs = C_base::M('admin.recruit')->qy_gw_s($qid,array('id'=>$id,'qid'=>$qid));
		$this->sh = C_base::M('admin.port')->linkage_ss(array('parent_id'=>'0'));//所有省列表
		if(@$this->rs['sheng']){
			$this->shi = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$this->rs['sheng']));
			if(@$this->rs['shi']){
				$this->qu = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$this->rs['shi']));
			}
		}
		$this->zhiwei = C_base::M('admin.recruit')->job_ss(array('sid'=>0));
		$this->hangye = C_base::M('admin.recruit')->industry_ss();//行业类别
	}
	/**
	 * 专家编辑岗位
	 */
	function zjia_gwbj(){
		$this->_is_html =1;
		extract($this->_post());
		if(@!$id ||  @!$qid){
			exit('非法操作');
		}
		$rs = C_base::M('admin.recruit')->qy_gw_s($qid,array('id'=>$id,'qid'=>$qid));
		if(@$rs){
			$post = util::quchu($this->_post(), 'id,qid,kstime,jstime');
			$post['kstime'] = strtotime($kstime);
			$post['jstime'] = strtotime($jstime);
			//print_r($post);
			$xiu = C_base::M('admin.recruit')->qy_gw_u($qid,array('id'=>$id,'qid'=>$qid),$post);
			if($xiu){
				exit('修改成功');
			}else{
				exit('error');
			}	
		}else{
			exit('数据已过期');
		}
	}
	
	function zjia_jianligl(){
		$this->tit ='简历下载历史';
		for($i=0;$i<=9;$i++){
			$rrs[$i] =  C_base::M('admin.recruit')->jlxz_ss($i,array('lx'=>1));
		}
		if(@$rrs){
			foreach ($rrs as $k=>$v){
				if($v){
					foreach ($v as $kk=>$vv){
						$this->rs[]=$vv;
					}
				}
			}
			if(@$this->rs){
				foreach ($this->rs as $k1=>$v1){
					$zz = C_base::M('admin.recruit')->user_s(array('qyid'=>$vv['qid']));
					if($zz){
						$this->rs[$k1]['zjid'] = $zz['id'];
					}
				}
			}
		}
		//print_r($this->rs);
	}
	/**
	 * 删除下载历史
	 * id 历史id
	 * qid 企业id
	 */
	function zjia_jianlidel(){
		$this->_is_html =1;
		extract($this->_post());
		$aa = C_base::M('admin.recruit')->jlxz_s($qid,array('id'=>$id,'qid'=>$qid));
		if(@$aa){
			$bb = C_base::M('admin.recruit')->jlxz_d($qid,array('id'=>$id,'qid'=>$qid));
			if($bb){
				exit('cg');
			}else{
				exit('error');
			}
		}else{
			exit('下载历史已过期');
		}
	}

	function zjia_gwdel(){
		$this->_is_html = 1;
		extract($this->_post());
		if(@!$id ||  @!$qid){
			exit('非法操作');
		}
		$rs = C_base::M('admin.recruit')->qy_gw_s($qid,array('id'=>$id,'qid'=>$qid));
		if($rs){
			$del = C_base::M('admin.recruit')->qy_gw_d($qid,array('id'=>$id,'qid'=>$qid));
			if($del){
				exit('cg');
			}else{
				exit('error');
			}
		}else{
			exit('数据已过期');
		}
	}
	
/**********************************客服管理*******************************************/
	function kefu(){//客服列表
		$this->tit = '客服';
		$this->r = C_base::M('kefu.fankui')->kfadmin_ss(array('id>'=>0));
	}
	
	function kefu_xz(){
		$this->tit = '客服新增';
	}
	
	function kefu_cj(){
		extract($this->_post());
		$w = array('username'=>$username);
		$ar = C_base::M('kefu.fankui')->kfadmin_s($w);
		if($ar){
			exit('当前用户名已被占用');
		}
		if(empty($qx)){
			exit('权限不能为空');
		}else{
			$qx = implode(',',$qx);
		}
		if(empty($pwd)){
			exit('密码不能为空');
		}else{
			C_base::dybase('util')->zfpd($pwd,'6','密码不能小于6个数字!','1');
		}
		$c = array('username'=>$username,'password'=>md5($pwd),'name'=>$name,'qx'=>$qx,'time'=>time());
		$r = C_base::M('kefu.fankui')->kfadmin_c($c);
		if($r > 0){
			exit('添加成功');
		}else{
			exit('添加失败');
		}
	}
	
	function kefu_update(){//客服编辑页面
		extract($this->_get());
		$this->tit = '客服信息';
		$w = array('id'=>$id);
		$this->r = C_base::M('kefu.fankui')->kfadmin_s($w);
		$this->r['qx'] = explode(',',$this->r['qx']);
	}
	
	function kefu_bj(){//编辑客服
		extract($this->_post());
		if(empty($qx)){
			exit('权限不能为空');
		}else{
			$qx = implode(',',$qx);
		}
		$w = array('id'=>$id);
		if(@$pwd){
			C_base::dybase('util')->zfpd($pwd,'6','密码不能小于6个数字!','1');
			$u = array('password'=>md5($pwd),'name'=>$name,'qx'=>$qx);
		}else{
			$u = array('name'=>$name,'qx'=>$qx);
		}
		$r = C_base::M('kefu.fankui')->kfadmin_u($w,$u);
		if($r == 1){
			exit('修改成功');
		}else{
			exit('修改失败');
		}
	}
	
	function kefu_delete(){//删除客服
		extract($this->_post());
		$w = array('id'=>$id);
		$r = C_base::M('kefu.fankui')->kfadmin_d($w);
		if($r == 1){
			exit('删除成功');
		}else{
			exit('删除失败');
		}
	}
	
	function kefu_type(){//冻结、解冻
		extract($this->_post());
		$w = array('id'=>$id);
		$u = array('dongjie'=>$dongjie);
		$r = C_base::M('kefu.fankui')->kfadmin_u($w,$u);
		if($r == 1){
			exit('ok');
		}else{
			exit('修改失败');
		}
	}
}